package com.imcoke.abchat.web.mapper;

import com.imcoke.abchat.domain.ChatRecord;
import org.apache.ibatis.annotations.*;

/**
 * @Author ccoke
 * @Description
 * @Date: 10:55 2018-01-13
 */
@Mapper
public interface ChatRecordMapper {
    /*
    * 插入聊天记录
    * */
    @Insert("INSERT INTO tb_chatrecord VALUES(#{id},#{relationshipid},#{userid},#{content},#{time),#{status}")
    @SelectKey(statement = "select last_insert_id()", keyProperty = "id", before = false, resultType = Long.class)
    int insertChatRecord(ChatRecord chatRecord);

    /*
    * 通过relationshipid获取聊天记录
    * */
    @Select("SELECT * FROM tb_chatrecord  WHERE relationshipid = #{relationshipid} ")
    ChatRecord selectChatRecordByRelationshipId(@Param("relationshipid") Long relationshipid);


    /*
    * 通过id删除聊天记录
    * */
    @Update("UPDATE tb_chatrecord SET status = 0 WHERE id = #{id}")
    int deleteChatRecordById(@Param("id") Long id);
}

